package com.zhiwei.version.git.service.impl;

import com.zhiwei.version.git.service.GitCredentialService;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.springframework.stereotype.Service;

/**
 * function
 * author zhiwei.yang
 * time 2020-3-4-11:00
 */
@Service
public class GitCredentialServiceImpl implements GitCredentialService {

    @Override
    public CredentialsProvider createCredential(String username, String password) {
        if(StringUtils.isEmpty(username) || StringUtils.isEmpty(password)){
            return null;
        }
        return new UsernamePasswordCredentialsProvider(username, password);
    }
}
